package yunquan.wang.base.web.taglib;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

import yunquan.wang.base.appcode.AppcodeHolder;

public class CodeValueTaglib extends TagSupport {
	/**
	 * 
	 */
 

	private String type;
	private Object key;

	public void setType(String type) {
		this.type = type;
	}

	public void setKey(Object key) {
		this.key = key;
	}
	public int doEndTag() throws JspException {
 
		JspWriter out = pageContext.getOut();
		if(key!=null){
		try {
			Object codeValue = AppcodeHolder.getCodeValue(type, key.toString());
			if (codeValue == null) {
				throw new JspException("码表未被初始化");
			}
			out.print(codeValue);
		} catch (IOException e) {
		}
		}
		return EVAL_PAGE;
	}
}
